#include "AddDialog.h"
#include<QLabel>
#include<QPushButton>>
#include<QLineEdit>
#include<QTextEdit>
#include<QWidget>
#include<QGridLayout>
#include<QHBoxLayout>
#include<QVBoxLayout>


AddDialog::AddDialog(QWidget * parent)
	:QDialog(parent)
{
	nameLabel_  = new QLabel(tr("Name"));
	addressLabel_ = new QLabel(tr("Address"));
	okButton_ = new QPushButton(tr("OK"));
	cancelButton_ = new QPushButton(tr("Cancel"));

	nameText_ = new QLineEdit;
	addressText_ = new QTextEdit;

	QGridLayout * gridLayout = new QGridLayout;
	gridLayout->setColumnStretch(1,2);
	gridLayout->addWidget(nameLabel_ , 0 ,0);
	gridLayout->addWidget(nameText_ , 0 ,1);

	gridLayout->addWidget(addressLabel_ , 1 ,0 ,Qt::AlignLeft|Qt::AlignTop);
	gridLayout->addWidget(addressText_ , 1,1,Qt::AlignLeft);


	QHBoxLayout * buttonLayout = new QHBoxLayout;
	buttonLayout->addWidget(okButton_);
	buttonLayout->addWidget(cancelButton_);

	gridLayout->addLayout(buttonLayout , 2 , 1 ,Qt::AlignRight);

	QVBoxLayout * mainLayout = new QVBoxLayout;
	mainLayout->addLayout(gridLayout);
	
	setLayout(mainLayout);

	connect(okButton_ , &QAbstractButton::clicked , this , &QDialog::accept);
	connect(cancelButton_ ,&QAbstractButton::clicked , this ,&QDialog::reject);

	setWindowTitle(tr("Add a Contact"));
}
